package com.yummiii.dokueditor.controller;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Properties;

public class PrefController {
	static final String prefFileName="settings.xml";
	Properties properties;
	
	public PrefController() throws FileNotFoundException, IOException{
		File prefFile=new File(prefFileName);
		properties=new Properties();
		properties.loadFromXML(new FileInputStream(prefFile));
	}
	
	public void save() throws FileNotFoundException, IOException{
		properties.storeToXML(new FileOutputStream(new File(prefFileName)), "", "utf-8");
	}
	
	public void setURL(String url){
		properties.setProperty("URL", url);
	}
	public String getURL(){
		return properties.getProperty("URL");
	}
	
	public void setUsername(String username){
		properties.setProperty("username",username);
	}
	public String getUsername(){
		return properties.getProperty("username");
	}
	public void setPassword(String password){
		properties.setProperty("password", password);
	}
	public String getPassword(){
		return properties.getProperty("password");
	}
}
